<?php
/*
Autor: Marek Křivan
(c) 2009 
*/

if(intval($_SESSION['rank']) < 2){
	exit(WRONG_PERMISSIONS);
}
$id_tematu = 1 * $q[2];
$seo = ($GLOBALS['seo']) ? '' : 'index.php?q=';
if(isset($_POST['neodeslat_form'])) {

                echo "<meta http-equiv=\"refresh\" content=\"1;".$GLOBALS['url'].$seo."forum/dues/".$id_tematu."/1\" />";
        } 
if((isset($q[3])) && ($_SESSION['rank'] >= 2)) {
                if(isset($_POST['zamknout'])) {
                        $query = $GLOBALS['db']->query("UPDATE " . $GLOBALS['db_prefix'] ."forum_temata SET zamknuto = '1' WHERE id = '$id_tematu';");
                        echo "<meta http-equiv=\"refresh\" content=\"1;".$GLOBALS['url'].$seo."forum/dues/".$id_tematu."/1\" />";
                } elseif(isset($_POST['odemknout'])) {
                        $query = $GLOBALS['db']->query("UPDATE " . $GLOBALS['db_prefix'] ."forum_temata SET zamknuto = '0' WHERE id = '$id_tematu';");
                        echo "<meta http-equiv=\"refresh\" content=\"1;".$GLOBALS['url'].$seo."forum/dues/".$id_tematu."/1\" />";
                } elseif($q[3] == 1) { 
                        echo "<form action=\"".$GLOBALS['url'].$seo."forum/action_zamk_odemk/".$id_tematu."/1\" method=\"post\"><fieldset><legend>Zamknout téma</legend><label>Přejete si zamknout toto téma?</label><input type=\"submit\" value=\"Ano\" name=\"zamknout\" /> <input type=\"submit\" value=\"Ne\" name=\"neodeslat_form\" /><br /><br /></fieldset></form>";
                } elseif($q[3] == 0) { 
                        echo "<form action=\"".$GLOBALS['url'].$seo."forum/action_zamk_odemk/".$id_tematu."/1\" method=\"post\"><fieldset><legend>Odemknout téma</legend><label>Přejete si odemknout toto téma?</label><input type=\"submit\" value=\"Ano\" name=\"odemknout\" /> <input type=\"submit\" value=\"Ne\" name=\"neodeslat_form\" /><br /><br /></fieldset></form>";
                }
                }
?>
